<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require_once 'Zend/Db/Table/Abstract.php';
class Admin_Models_AdminMenuModel extends Zend_Db_Table_Abstract
{
    /**
     * The default table name 
     */
    protected $_name = 'menu';
    protected $_primary = 'id';
    function loadmainmenu(){
       $db = Zend_Db_Table::getDefaultAdapter();
       $sql = $db->select()->from('menu')->where('parent = 0');
       $result = $db->fetchAll($sql);
       return $result;        
    }
    function loadsubmenu($parent_id){
         $db = Zend_Db_Table::getDefaultAdapter();
       $sql = $db->select()->from('menu')->where('parent = '.$parent_id);
       $result = $db->fetchAll($sql);
       return $result;        
    }
    function loaduserinfobyid($uid){
        $db = Zend_Db_Table::getDefaultAdapter();  
        $sql=$db->select()->from('userinfo',array("UserID","Username","Avatar"))->where("UserID='".$uid."'");

        $result = $db->fetchAll($sql);
        return $result;
    }
     public function getProductById($ProductID){
            $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        	$mySql = $db->select()
        				->from($this->_name)
                        ->where('ProductID = ?',$ProductID);
            
            $result = $db->fetchRow($mySql);
            return $result;
    }
}
?>
